package com.zzyl.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.NursingProjectMapper;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

@Service
public class NursingProjectServiceImpl implements NursingProjectService {

    @Autowired
    private NursingProjectMapper nursingProjectMapper;
    @Override
    public PageResponse<NursingProjectVo> findByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        Page<NursingProject> nursingProjectResponseResult = nursingProjectMapper.selectByPage(name,status);
        PageResponse<NursingProjectVo> response = PageResponse.of(nursingProjectResponseResult, NursingProjectVo.class);
        return response;
    }

    @Override
    public void save(NursingProject nursingProject) {
        nursingProjectMapper.insert(nursingProject);
    }

    @Override
    public NursingProjectVo findById(Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectMapper.selectById(id);
        return nursingProjectVo;
    }

    @Override
    public void update(NursingProject nursingProject) {
        nursingProjectMapper.update(nursingProject);
    }

    @Override
    public void updateStatus(Long id, Integer status) {
        nursingProjectMapper.updateStatus(id,status);
    }

    @Override
    public void deleteById(Long id) {
        nursingProjectMapper.deleteById(id);
    }

    @Override
    public List<NursingProjectVo> findAll() {
        List<NursingProjectVo> list = nursingProjectMapper.selectAll();
        return list;
    }
}
